<script type="text/javascript">
function deleteSchedule(id) {
    _common.del(null, id, "${basePath}/schedule/deleteSchedule",null,function(){
    	_tabs.showPage("list",null,null,null)});
}
function scheduleResume(id){
    $.post("${basePath}/schedule/scheduleResume",{"id":id},function(data){
        if(data.code!=0){
            MessageBox.error("任务启动失败！");
            return;
        }
    })
}
function scheduleStop(id){
    $.post("${basePath}/schedule/scheduleStop",{"id":id},function(data){
        if(data.code!=0){
            MessageBox.error("任务暂停失败！");
            return;
        }
    })
}

function scheduleStop(id){
    $.post("${basePath}/schedule/scheduleStop",{"id":id},function(data){
        if(data.code!=0){
            MessageBox.error("任务暂停失败！");
            return;
        }
    })
}

function popUpParams(id){
	$("#params").val("");
	$("#id").val(id);
	$('#jobParams').modal('show');
}

function triggerJob(id,params){
    $.post("${basePath}/schedule/triggerJob",{"id":id,"param":params},function(data){
        if(data.code!=0){
            MessageBox.error("任务启动失败！");
            return;
        }else{
        	 MessageBox.error("任务启动成功。");
        }
    })
}

$("#jobParams_save").click(function(){
	var id=$("#id").val();
	var params=$("#params").val();
	triggerJob(id,params);
})
$("#jobParams_close").click(function(){
	$('#jobParams').modal('hide');
})

function viewAddPage(id) {
	if(id!=null){
        _tabs.showPage("information",null,'ID=' + id,null);
    }else {
        _tabs.showPage("information",null,null,null);
    }
}
</script>
<section class="content">
	<div class="box">
			<div class="box-body">
				<div class="row marginZero">
						<epoch:table id="scheduleJobTable" queryUrl="${basePath}/sys/job/findJobListAjax" rowId="id" showRefresh="true" onDelClick="onDelete"
					                 onAddClick="addClick" newBtn="true" delBtn="true">
					        <epoch:tr check="checkbox" titleTip="全选"></epoch:tr>
					        <epoch:tr name="任务名称" formName="job_name"><a href="javascript:void(0);"
					                                            onclick="viewAddPage('~{row.id}')">~{row.job_name}</a></epoch:tr>
					        <epoch:tr name="任务组" formName="job_group" filterType="select"
					               filterData="${lisFun.dictForFilter('PUB_SYS_MODULE')}"></epoch:tr>
					        <epoch:tr name="状态" formName="job_status" filterType="select"
					               filterData="${lisFun.dictForFilter('SYS_JOB_STATUS')}"></epoch:tr>
					        <epoch:tr name="目标类" formName="target_class"></epoch:tr>
					        <epoch:tr name="Cron 表达式" formName="CRON_EXPRESSION"></epoch:tr>
					        <epoch:tr name="任务描述" formName="job_desc"></epoch:tr>      
					        <epoch:tr name="操作" switchable="false">
					            <i class="fa fa-trash-o" style="cursor:pointer;color:red" aria-hidden="true" onclick="deleteSchedule('~{row.id}');" title="删除">  </i>
					            &nbsp;&nbsp;
					            <i class="fa fa-play" style="cursor:pointer;color:red" aria-hidden="true" onclick="scheduleResume('~{row.id}');" title="启动">  </i>
					            &nbsp;&nbsp;
					            <i class="fa fa-pause" style="cursor:pointer;color:red" aria-hidden="true" onclick="scheduleStop('~{row.id}');" title="暂停">  </i>
					            &nbsp;&nbsp;
					            <i class="fa fa-step-forward" style="cursor:pointer;color:red" aria-hidden="true" onclick="popUpParams('~{row.id}');" title="立即执行">  </i>
					        </epoch:tr>
					    </epoch:table>
					    <epoch:winOpen id="jobParams" title="立即执行" showSaveBtn="true" showCloseBtn="true" width="50%" btnSave="保存">
					    	<div class="box">
					    		<div class="row visa-row">
					    			<div class="row w-row">
							        	<div class="col-md-2 col-sm-12 col-xs-12 w-row1">
							        	参数
							        	</div>
							        	<div class="col-md-10 col-sm-12 col-xs-12 w-row1">
							        		<input id="id" type="hidden" name="id"/>
							        		<textarea id="params" style="resize:none" cols="70" rows="2"></textarea>
							        	</div>
							        </div>
					    		</div>
					    	</div>
					    </epoch:winOpen>
				</div>
			</div>
	</div>
</section>